package pathfinder;


// Data structure for pathfinding
public class Point implements Comparable<Point> {

  public int x, y, xDes, yDes, cost;

  Point() {
    x = 0;
    y = 0;
    xDes = 0;
    yDes = 0;
    cost = 0;
  }
  
  Point(int x, int y) {
    this.x = x;
    this.y = y;
    xDes = 0;
    yDes = 0;
    cost = 0;
  }

  Point(int x, int y, int xDes, int yDes) {
    this.x = x;
    this.y = y;
    this.xDes = xDes;
    this.yDes = yDes;
    cost = 0;
  }
  
  Point(int x, int y, int xDes, int yDes, int cost) {
    this.x = x;
    this.y = y;
    this.xDes = xDes;
    this.yDes = yDes;
    this.cost = cost;
  }

  // heuristic function
  public double trueRange() {
    return Math.sqrt(Math.pow(x - xDes, 2) + Math.pow(y - yDes, 2));
  }

  // use comparator to sort priority queue
  @Override
  public int compareTo(Point o) {
    return (int) this.trueRange() - (int) o.trueRange();
  }
}
